﻿//define(['jquery'], function($) {
define(function() {
	/*
	String.prototype.format = function() {
		var args = arguments;
		console.log("args=" + args.length);
		// for(let i in args) {
			// console.log("i=" + args[i]);
		// }
		return this.replace(/\{(\d+)\}/g, function(m, i) {
			console.log(m + "   ====   " + i);
			console.log("args[i]=" +args[i]);
			return args[i];
		});
	};
	console.log("{998599999}".format('yiyiy'));
	*/
	
	var bingEvent = function() {
		$(".level1 > a").unbind().click(function() {
			var ul = $(this);
			if(ul.attr("class")) {
				ul.removeClass("current").next().hide();
			} else {
				ul.addClass("current")   //给当前元素添加"current"样式
				.next().show()                //下一个元素显示
				.parent().siblings().children("a").removeClass("current")        //父元素的兄弟元素的子元素<a>移除"current"样式
				.next().hide();                //它们的下一个元素隐藏
				return false;
			}
		});
		
		///*
		// function logArrayElements(element, index, array) {
			// console.log('a[' + index + '] = ' + element);
			// console.log(array);
		// };
		[2, 5, , 9].forEach((e, i, array) => {
			console.log('a[' + i + '] = ' + e);
			console.log(array);
		});
		//*/
		
		/*
		var sum = 0;
		var obj = {prop1: 5, prop2: 13, prop3: 8};
		for (var item in obj) {
		  sum += obj[item];
		}
		console.log(sum); // prints "26", which is 5+13+8
		*/
		//ssss
		
	};

	return {
		init : function() {
			bingEvent();
		}
	};

});